<template>
  <div>
    <HomeHeader></HomeHeader>
    <TypeNav></TypeNav>
    <el-form>
      <div class="plan-box">
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/' }">盛世绿能招投标系统</el-breadcrumb-item>
          <el-breadcrumb-item >采购信息</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="plan-grid-content">
          <h1 style="text-align: center;padding-top: 20px;">采购信息</h1>
          <el-table v-loading="loading" :data="planList">
            <el-table-column label="序号" align="center" prop="aid" width="60">
              <template slot-scope="scope">
                {{ scope.$index + 1 }}
              </template>
            </el-table-column>
            <el-table-column label="采购计划编号" align="center" prop="aaCode" width="180"/>
<!--            <el-table-column label="采购业务类型" align="center" prop="aBtype" width="100">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.ppm_procurement_plan" :value="scope.row.aBtype"/>
              </template>
            </el-table-column>-->
            <el-table-column label="采购计划名称" align="center" prop="aName"/>

            <el-table-column label="创建人" align="center" prop="createBy"/>
<!--            <el-table-column label="创建部门" align="center" prop="aCreateDept"/>-->
            <el-table-column label="创建时间" align="center" prop="createTime"/>
            <el-table-column label="修改时间" align="center" prop="updateTime"/>
<!--            <el-table-column label="采购计划状态" align="center" prop="aAstate">
              <template slot-scope="scope">
                <el-tag type="danger" v-if="scope.row.aAstate === 2">已生效</el-tag>
                <el-tag v-else>未生效</el-tag>
              </template>
            </el-table-column>-->
            <el-table-column label="采购方式(招标/非招标项目)" align="center" prop="toProject" width="250"/>
            <el-table-column label="操作" align="center" class-name="small-padding" width="150">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.toProject.includes('公开')">
                  <router-link :to="'/planDetail?aid='+scope.row.aid+'&aaCode='+scope.row.aaCode+'&aBtype='+scope.row.aBtype+'&aAstate='+scope.row.aAstate">
                    <el-button size="small" type="primary">查看详情</el-button>
                  </router-link>
                </el-tag>
              </template>
            </el-table-column>
          </el-table>
          <pagination
              v-show="total>0"
              :total="total"
              :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize"
              @pagination="Info"
          />
        </div>
      </div>
    </el-form>
    <HomeFloor></HomeFloor>
  </div>
</template>
<script>
import HomeFloor from "@/components/home/HomeFloor.vue";
import HomeHeader from "@/components/home/HomeHeader";
import TypeNav from "@/components/home/TypeNav";
import Pagination from "@/components/Pagination/index.vue";
import {listPlan} from '@/api/system/procurement.js';


export default {
  name: 'planList',
  components:{
    HomeHeader,
    TypeNav,
    HomeFloor,
    Pagination
  },
  data() {
    return {
      planList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        aBtype: null
      },
      loading: false,
      total: 0
    }
  },
  created() {
    this.Info();
  },
  methods: {
    //查询招标公示
    Info() {
      this.loading = true;
      this.planList = [];
      let bsSupplier = sessionStorage.getItem("bsSupplier");
      let hid = 0;
      if(bsSupplier){
        hid = JSON.parse(bsSupplier).hid;//拿到供应商id
      }
      this.queryParams.hid = hid;
      listPlan(this.queryParams).then(response => {
        this.loading = false;
        this.planList = response.data.rows;
        this.total = response.data.total;
      }).catch(err => {
        this.$modal.msgError("服务器出错，请联系管理员！！！");
      });

    },
    calculateRemainingDays(uEndTime) {
      // 将字符串转换为日期对象
      const updateTime = new Date(uEndTime);
      // 计算当前日期与公示时间的差值，并返回剩余天数
      return Math.ceil(Math.abs(Date.now() - updateTime) / (1000 * 60 * 60 * 24));
    },
  }
}

</script>
<style>
.plan-box {
  width: 1400px;
  min-height: 800px;
  margin: 10px auto;
}

.el-tag {
  background-color: #ecf5ff;
  border-color: #d9ecff;
  height: 34px;
  padding: 0 0px;
  line-height: 30px;
  font-size: 12px;
  color: #0065B5;
  border-width: 1px;
  border-style: solid;
  border-radius: 4px;
  box-sizing: border-box;
  white-space: nowrap;
}

.plan-grid-content {
  background-color: white;
  margin-top: 21px;
  width: 1400px;
  min-height: 800px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

p {
  margin: 10px 0;
}

.demo-table-expand label {
  width: 120px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 80%;
}
/*按钮颜色*/
.el-button--primary {
  color: #FFF;
  background-color: #0065B5;
  border-color: #0065B5;
}
</style>
